An Operational Semantics of Lexically-Scoped Dynamic Variables

نویسنده

  • Sameer Sundresh
چکیده

Lexical and dynamic scoping are the two primary approaches to variable binding in functional programming languages. While medieval Lisp dialects commonly featured dynamic scoping, most languages today emphasize lexical scoping. This is a sensible choice: lexical scoping enables local reasoning about programs at the source code level. Nonetheless, dynamic variables are more appropriate for certain use cases, including implicit parameter passing. But do we really have to choose between lexical and dynamic scoping? A few systems, including the fluid-let macro and parameter objects in Scheme provide lexically-scoped dynamic variables. The semantics of such systems has thus far been presented only as implementations in terms of unrestricted mutable variables (e.g., using the set! operation). This article introduces λLD, a simple extension to the call-byvalue λ-calculus that supports lexically-scoped dynamic variables. The semantics of λLD does not rely upon any form of mutable state; and it is equivalent to the λ-calculus on terms not involving dynamic variables. Terms, including those containing dynamic variables, can be independently simplified and later composed; this allows for concurrent evaluation. The semantics of λLD has been implemented as a rewrite theory in Maude, allowing examples to be executed. The article shows how λLD can be used to model other forms of dynamic variables, as well as unique values, records and (functional) objects.

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Dynamically Scoped Functions for Runtime Modification

The importance of lexically scoped variable and function definitions is acknowledged in almost all programming languages. However, there are only few languages that provide dynamically scoped variables as well in spite of their usefulness. Furthermore, dynamically scoped functions have been largely dismissed. This paper provides a new perspective on dynamically scoped functions and sketches a d...

متن کامل

Program Transformation with Scoped Dynamic Rewrite Rules

The applicability of term rewriting to program transformation is limited by the lack of control over rule application and by the context-free nature of rewrite rules. The first problem is addressed by languages supporting user-definable rewriting strategies. The second problem is addressed by the extension of rewriting strategies with scoped dynamic rewrite rules. Dynamic rules are defined at r...

متن کامل

Relating Two Semantics of Locally Scoped Names

The operational semantics of programming constructs involving locally scoped names typically makes use of stateful dynamic allocation: a set of currently-used names forms part of the state and upon entering a scope the set is augmented by a new name bound to the scoped identifier. More abstractly, one can see this as a transformation of local scopes by expanding them outward to an implicit top-...

متن کامل

Safe Locking for Multi-threaded Java

There are many mechanisms for concurrency control in high-level programming languages. In Java, the original mechanism for concurrency control, based on synchronized blocks, is lexically scoped. For more flexible control, Java 5 introduced non-lexical operators, supporting lock primitives on re-entrant locks. These operators may lead to run-time errors and unwanted behavior; e.g., taking a lock...

متن کامل

Safe locking for multi-threaded Java with exceptions

There are many mechanisms for concurrency control in high-level programming languages. In Java, the original mechanism for concurrency control, based on synchronized blocks, is lexically scoped. For more flexible control, Java 5 introduced non-lexical lock primitives on re-entrant locks. These operators may lead to runtime errors and unwanted behavior; e.g., taking a lock without releasing it, ...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2008